package dxbridge.model;

import java.util.List;
import java.util.Map;

import dxbridge.model.IRecord;


public interface ITable {

    /**
     * Get all the key field names in this table.
     * 
     * @return String[] Key field names .
     */
    public abstract String[] getKeyFieldNames();

    /**
     * Get field name for given index
     * 
     * @param index
     * @return The field name for given index, if index out of bound, return
     *         null
     */
    public abstract String getFieldName(int index);


    /**
     * Get index of the given field.
     * 
     * @param fieldName
     * @return The index of given field, if not found the field name, return -1
     */
    public abstract int getIndexOfField(String fieldName);

 

    /**
     * Get how many fields are there in this table.
     * 
     * @return Field count in this table.
     */
    public abstract int getFieldCount();

    /**
     * Insert a record in this table
     * 
     * @param record
     *            A record to be insert
     */
    public abstract void insertRecord(IRecord record);

    /**
     * Get xpath to select this table. mainly used by {@link Record#getXPath()}.
     * 
     * <pre>
     * For example :
     * &quot;/xmlroot/cd_mstr&quot;
     * &quot;/xmlroot/brw_mstr/brwt_det&quot;
     * </pre>
     * 
     * @return The xpath string which can select to this table.
     */
    public abstract String getXpath();

    /**
     * Compare two table by it's depth.
     */
    public abstract int compareTo(ITable arg0);

    /**
     * Get "DB.Table" name , typically ,it is "PUB.table_name"
     * 
     * @return DB.Table name
     */
    public abstract String getTableNameWithDBName();

    /**
     * Get {@link #depth} of this table.
     * 
     * @return depth of table.
     */
    public abstract int getDepth();

    /**
     * If the given index is key.
     */
    public abstract boolean isIndexKey(int index);

    public abstract void setDepth(int depth);

    public abstract List<IRecord> getRecords();

    public abstract void setRecords(List<IRecord> records);

    public abstract ITable getParent();

    public abstract void setParent(ITable parent);

    public abstract String[] getFieldNames();

    public abstract void setFieldNames(String[] fieldNames);

    public abstract int[] getKeyIndex();

    public abstract void setKeyIndex(int[] keyIndex);

    public abstract String getTableName();

    public abstract void setTableName(String tableName);

    public abstract Map<String, String> getForeignKeyMap();

    public abstract void setForeignKeyMap(Map<String, String> foreignKeyMap);


    public abstract String[] getFieldTypes();

    public abstract void setFieldTypes(String[] fieldTypes);

    public abstract void printTest();

}